package DataStructure.tree;

import DataStructure.linear.Queue;

public class BinaryTreeErgodicTest {
    public static void main(String[] args) {
        //创建数对象
        BinaryTree<String, String> tree = new BinaryTree<>();
        //往树中添加对象
        tree.put("E","5");
        tree.put("B","2");
        tree.put("G","7");
        tree.put("A","1");
        tree.put("D","4");
        tree.put("F","6");
        tree.put("H","8");
        tree.put("C","3");

        //前序遍历
        System.out.println("================前序遍历===================");
        Queue<String> prekeys = tree.preErgodic();
        for (String key : prekeys) {
            String value = tree.get(key);
            System.out.println(key+"------"+value);//E B A D C G F H
        }

        System.out.println("===================中序遍历==================");
        Queue<String> midkeys = tree.midErgodic();
        for (String key : midkeys) {
            String value = tree.get(key);
            System.out.println(key+"------"+value);//A B C D E F G H
        }



        System.out.println("===================后序遍历==================");
        Queue<String> afterkeys = tree.afterErgodic();
        for (String key : afterkeys) {
            String value = tree.get(key);
            System.out.println(key+"------"+value);//A C D B F H G E
        }




        System.out.println("===================层次遍历==================");
        Queue<String> layerkeys = tree.layerErgodic();
        for (String key : layerkeys) {
            String value = tree.get(key);
            System.out.println(key+"------"+value);//E B G A D F H C
        }

        System.out.println(tree.maxDepth());
    }
}
